package com.my.chapter10;

public class practice14 {
    public static void main(String[] args) {
        Outer14 o = new Outer14();
        Monster m = o.getDangerousMonster();
        Lethal l = o.getVampire();
        m.menace();
        l.kill();
    }
}

interface Monster{
    void menace();
}

interface Lethal{
    void kill();
}

class Outer14{
    public Monster getDangerousMonster(){
        return new Monster() {
            @Override
            public void menace() {
                System.out.println("Monster.menace()");
            }
            public void destroy(){//扩展的方法
                System.out.println("Monster.destroy()");
            }
        };
    }

    public Lethal getVampire(){
        return new Lethal() {
            @Override
            public void kill() {
                System.out.println("Lethal.kill()");
            }
            public void drinkBlood(){
                System.out.println("Lethal.dringkBlood()");
            }
        };
    }

}
